package com.shd.edanpei.ui.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseViewHolder;
import com.shd.edanpei.R;
import com.shd.edanpei.base.BaseQuickImageAdapter;
import com.shd.edanpei.bean.MessageModel;

public class MsgAdapter extends BaseQuickImageAdapter<MessageModel> {

    public MsgAdapter(Context context) {
        super(context, R.layout.message_item);
    }

    @Override
    protected void convert(BaseViewHolder helper, MessageModel item) {
        int layoutPosition = helper.getLayoutPosition();
        if (layoutPosition == 0) {
            helper.getView(R.id.tv_message_top).setVisibility(View.VISIBLE);
        } else {
            helper.getView(R.id.tv_message_top).setVisibility(View.GONE);
        }
        if (item.isStatus()) {
            //未读
            ((ImageView) helper.getView(R.id.iv_message)).setImageResource(R.drawable.ic_message_unread);
        } else {
            //已读
            ((ImageView) helper.getView(R.id.iv_message)).setImageResource(R.drawable.ic_message_read);
        }
        helper.setText(R.id.tv_message_title, item.getTitle())
                .setText(R.id.tv_message_content, item.getMessage())
                .setText(R.id.tv_message_time, item.getCreateTime());
    }
}
